#!/bin/sh

# This is the general driver used by the testsuite to run tests by
# "make check" in the tests directory. It gets processed by a
# simple-minded sed script to fill in the lisp implementation etc
# below and turns into <lispname>-test.sh

LOCAL_MAXIMA="!LOCAL_MAXIMA!"
OUTPUT_LOG="!OUTPUT_LOG!"
LISP="!LISPNAME!"

# Die if a command fails
set -e

# This command doesn't exit with a helpful status if the lisp survives
# but the test fails so we must check by hand that nothing untoward
# happened
$LOCAL_MAXIMA --lisp=$LISP --batch-string="run_testsuite();" \
  </dev/null 2>&1 | tee "$OUTPUT_LOG"

grep -q 'No unexpected errors' <"$OUTPUT_LOG"

# We'll have another copy of the log from the output of this script,
# so there's no point in leaving the greppable one lying around.
rm "$OUTPUT_LOG"
